


interface ComputerWeight{
    public double computerWeight();
}

class Television implements ComputerWeight{

    @Override
    public double computerWeight() {
        // TODO 自动生成的方法存根
        return 3.5;
    }
}
class Computer implements ComputerWeight{

    @Override
    public double computerWeight() {
        // TODO 自动生成的方法存根
        return 2.67;
    }

}

class WashMachine implements ComputerWeight{

    @Override
    public double computerWeight() {
        // TODO 自动生成的方法存根
        return 13.8;
    }

}

class Truck{
    ComputerWeight[] goods;
    double totalWeights=0;
    Truck(ComputerWeight[] huowus){
        this.goods = huowus;
    }
    public void setGoods(ComputerWeight[] huowus) {
        this.goods =huowus;
    }
    public double getTotalWeight() {
        totalWeights =0;
        for (int i = 0; i < goods.length; i++) {
            totalWeights+=goods[i].computerWeight();
        }
        return totalWeights;
    }
}


public class Estimator {
    public static void main(String[] args) {
        ComputerWeight[] goods = new ComputerWeight[650];
        for (int i = 0; i < goods.length; i++) {
            if (i % 3 == 0)
                goods[i] = new Television();
            else if (i % 3 == 1)
                goods[i] = new Computer();
            else if (i % 3 == 2)
                goods[i] = new WashMachine();

        }

        Truck truck = new Truck(goods);
        System.out.printf("\n货车装载的货物重量：%-8.5f kg\n", truck.getTotalWeight());
        goods = new ComputerWeight[68];
        for (int i = 0; i < goods.length; i++) {
            if (i % 2 == 0)
                goods[i] = new Television();
            else
                goods[i] = new WashMachine();

        }
        truck.setGoods(goods);
        System.out.printf("货车装载的货物重量：%-8.5f kg\n", truck.getTotalWeight());

    }
}